<?php
require_once(dirname(__FILE__)."/../core/safeParam.php");
class module
{
  function Add($vars)
  {
    global $database;
    $action['max_toppings'] = $vars['max_toppings'];
    $action['name']         = $vars['name'];
    $action['multi']        = $vars['multi'];
    $action['cid']          = serialize($vars['cid']);
    $action['global']       = '1';
    $action['rid']          = $vars['rid'];
    $database->insert_array('options_set', $action);
    header("Location: ../admin/index.php?edit=global-options&updated=1");
  }
  function Edit($vars)
  {
    global $database;
    $action['max_toppings'] = $vars['max_toppings'];
    $action['name']         = $vars['name'];
    $action['multi']        = $vars['multi'];
    $action['cid']          = serialize($vars['cid']);
    $action['global']       = '1';
    $database->update_array('options_set', $action, "id = " . $vars['id'] . "");
    header("Location: ../admin/index.php?edit=global-options&updated=1");
  }
  function Delete($vars)
  {
    global $database;
    $database->delete('options_set', "id = " . $vars['id'] . "");
    header("Location: ../admin/index.php?edit=global-options&updated=1");
  }
  function AddOption($vars)
  {
    global $database;
    $action['name']   = $vars['name'];
    $action['price']  = $vars['price'];
    $action['parent'] = $vars['parent'];
    $database->insert_array('options_items', $action);
    header("Location: ../admin/index.php?edit=global-options&cid=" . $action['parent'] . "&updated=1");
  }
  function EditOption($vars)
  {
    global $database;
    $action['name']   = $vars['name'];
    $action['price']  = $vars['price'];
    $action['parent'] = $vars['parent'];
    $database->update_array('options_items', $action, "id = " . $vars['id'] . "");
    header("Location: ../admin/index.php?edit=global-options&cid=" . $action['parent'] . "&updated=1");
  }
  function DeleteOption($vars)
  {
    global $database;
    $database->delete('options_items', "id = " . $vars['id'] . "");
    header("Location: ../admin/index.php?edit=global-options&cid=" . $vars['parent'] . "&updated=1");
  }
}
?>
